cmake_minimum_required (VERSION 2.8)
project(mysql_api)

IF(WIN32)
	set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin)
ELSEIF(UNIX)
	set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin/gcc_x64)
ENDIF()

include_directories(${PROJECT_SOURCE_DIR}/mysql)

if(MSVC)
	#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()

IF(WIN32)
	set(PRO_MYSQL_LIB ${PROJECT_SOURCE_DIR}/mysql/vc_x86/libmysql.lib)
ENDIF()

IF(UNIX)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-rpath=.")
ENDIF()

ADD_EXECUTABLE(mysql_api ${PROJECT_SOURCE_DIR}/src/main.cpp ${PROJECT_SOURCE_DIR}/src/mysqlapi.cpp)

IF(WIN32)
TARGET_LINK_LIBRARIES(mysql_api ${PRO_MYSQL_LIB})
ELSEIF(UNIX)
TARGET_LINK_LIBRARIES(mysql_api -lmysqlclient)
ENDIF()
